﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>OutBox</title>
</head>
<body>
	<h1>OutBox</h1>

	<?php
		$dbc = mysqli_connect( 'localhost' ,'root' , '', 'teresa' ) or die( 'Error connecting to MySQL server.');		
		$email = $_COOKIE[ 'user_email' ];
  
      
		$query = "SELECT * FROM teresa_message WHERE sender = '$email' AND reciever = 'sender'";
		$data = mysqli_query( $dbc , $query) or die('ERROR queerying database.');
		
		$number = 1;
		
			
		echo '<table>';
		
		while( $row = mysqli_fetch_array( $data ) ){
			$subject = $row['subject'];
		//	$maximum = $row['maximum'];
		//	$send_date = $row['send_date'];
		//	$maximum = $row['maximum'];
		//	$message = $row['message'];
			$send_date = $row['send_date'];
			$message_id = $row['message_id'];
			$address = $row['address'];
			
			echo '<tr class="sendrow"><td></td>';
			echo	'<td>' . $number . '</td>';
			echo	'<td><strong>' . $subject . '</strong></td>';
			echo '<td><a href="show_outbox_message.php?message_id=' . $message_id  . '">read more...</a></td>' ;
			echo	'<td>' . $send_date . '</td>';
			echo '</tr>';

			$number = $number + 1;
		}

		echo '</table>';

		mysqli_close($dbc);
		echo '<a href="main.php">Return to Main</a>'
	?>
</body>
</html>
